home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / c_course.zip / SCOPE.C < prev    next >
Text File  |  1989-12-30  |  1KB  |  41 lines

  1. int count;        /* This is a global variable */
  2.  
  3. main()
  4. {
  5. register int index; /* This variable is available only in main */
  6.  
  7.    head1();
  8.    head2();
  9.    head3(); 
  10.                       /* main "for" loop of this program */
  11.    for (index = 8;index > 0;index--) {
  12.       int stuff;  /* This variable is only available in these braces*/
  13.       for (stuff = 0;stuff <= 6;stuff++)
  14.          printf("%d ",stuff);
  15.       printf(" index is now %d\n",index);
  16.     }
  17. }
  18.  
  19. int counter;      /* This is available from this point on */
  20. head1()
  21. {
  22. int index;        /* This variable is available only in head1 */
  23.  
  24.    index = 23;
  25.    printf("The header1 value is %d\n",index);
  26. }
  27.  
  28. head2()
  29. {
  30. int count;  /* This variable is available only in head2 */
  31.             /* and it displaces the global of the same name */
  32.  
  33.    count = 53;
  34.    printf("The header2 value is %d\n",count);
  35.    counter = 77;
  36. }
  37.  
  38. head3()
  39. {
  40.    printf("The header3 value is %d\n",counter);
  41. }